import { SET_CATEGORYLIST_STATE } from "../constant-type";
import { reqcList } from "@/api";

const state = {
	categoryList: [],
};
const mutations = {
	[SET_CATEGORYLIST_STATE](state, payload) {
		state.categoryList = payload.categoryList;
	},
};
const actions = {
	async getCategoryList({ commit }) {
		try {
			const re = await reqcList();
			// console.log(re);
			commit(SET_CATEGORYLIST_STATE, { categoryList: re });
		} catch (e) {
			alert(e.message);
		}
	},
};
const getters = {};

export default {
	namespaced: true,
	state,
	mutations,
	actions,
	getters,
};
